C# Image.Clone to byte[] causes EDIT.COM to open on Windows XP

Posted by JayDial on Stack Overflow See other posts from Stack Overflow or by JayDial
Published on 2010-03-15T15:30:25Z Indexed on 2010/03/15 15:39 UTC
Read the original article Hit count: 258

Filed under:
|
|

It appears that cloning a Image and converting it to a byte array is causing EDIT.COM to open up on Windows XP machines. This does not happen on a Windows 7 machine. The application is a C# .NET 2.0 application. Does anyone have any idea why this may be happening?

Here is my Image conversion code:

        public static byte[] CovertImageToByteArray(Image imageToConvert)
    {
        imageToConvert.Clone() as Image;

        if(clone == null)
            return null;

        imageToConvert.Dispose();

        byte[] imageByteArray;
        using (MemoryStream ms = new MemoryStream())
        {
            clone.Save(ms, clone.RawFormat);
            imageByteArray = ms.ToArray();
        }

        return imageByteArray;
    }


    public static Image ConvertByteArrayToImage(byte[] imageByteArray,
                                                ImageFormat formatOfImage)
    {
        Image image;

        using (
            MemoryStream ms = new MemoryStream(imageByteArray, 0,
                                               imageByteArray.Length))
        {
            ms.Write(imageByteArray, 0, imageByteArray.Length);
            image = Image.FromStream(ms, true);
        }

        return image;
    }

Thanks

Justin

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows-xp